package com.usian.service.impl;

import com.usian.mapper.UserMapper;
import com.usian.pojo.Product;
import com.usian.pojo.User;
import com.usian.service.ProductService;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Product> findAll() {
        int id = 2;
        return userMapper.findAll(id);
    }

    @Override
    public void delete(Integer id) {
        userMapper.deleteById(id);
    }

    @Override
    public Product selectId(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public void insert(Product product) {
        product.setStatus(0);
        userMapper.insert(product);
    }

    @Override
    public void update(Product product) {
        userMapper.updateById(product);
    }

    @Override
    public void qy(Integer id) {
        Product product = userMapper.selectById(id);
        if (product.getStatus()==1){
            product.setStatus(0);
        }else if (product.getStatus()==0){
            product.setStatus(1);
        }
        userMapper.updateById(product);
    }

    @Override
    public List<Product> sh() {
        int ztai = 1;
        return userMapper.sh(ztai);
    }

    @Override
    public void s(Integer id) {
        Product product = userMapper.selectById(id);
        product.setStatus(2);
        userMapper.updateById(product);
    }

}
